package com.jay.net.clazz.socket.options;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;

public class ReceiveBufferSize {
	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = new ServerSocket(8000);
		System.out.println(serverSocket.getReceiveBufferSize());

		ServerSocket serverSocket1 = new ServerSocket();
		int size = serverSocket.getReceiveBufferSize();
		if (size < 131072) {
			// 把缓冲区的大小设为128K,如果大于64K，就一定要在bind前设置
			serverSocket.setReceiveBufferSize(131072);
		}
		// //与8000端口绑定
		serverSocket1.bind(new InetSocketAddress(8001));

//		Socket clientSocket = new Socket("localhost", 8002);
//		System.out.println(serverSocket.getReceiveBufferSize());
//
//		Socket clientSocket1 = new Socket();
//		size = serverSocket.getReceiveBufferSize();
//		if (size < 131072) {
//			// 把缓冲区的大小设为128K,如果大于64K，就一定要在bind前设置
//			clientSocket1.setReceiveBufferSize(131072);
//		}
//		// //与8000端口绑定
//		clientSocket1.bind(new InetSocketAddress(8003));
	}
}
